<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
		<script language="javascript">
	function docheck() {
		if (document.frmmsg.to.value == "") {
			alert(" ‘ 发送至 ’ 选项为空值，请确认。");
			return false;
		}
		if (document.frmmsg.title.value == "") {
			alert("标题选项为空值，请确认。");
			return false;
		}
		
		if (document.frmmsg.to.value.length > 100) {
			alert("接收的用户过多，请每次发送的用户不要超出20位");
			return false;
		}
		
		if (document.frmmsg.title.value.length > 50) {
			alert("标题超出了规定的长度。");
			return false;
		}

		return true;
	}
	function changeHTML() {//将编辑框内容写为HTML，为写入数据库做准备。
		if (document.getElementById("content_value").value != "") {
			document.getElementById("content").value = document
					.getElementById("content_value").innerHTML;
		}
	}
	function show_list(id, gname, boxname) {//第一参数为存放最后获取多选框所有值的标签id；第二参数为多选框分组的组名；第三参数为多选框框架名。
		var e_str = '';
		var obj = document.getElementById(id);
		var obj_box = document.getElementById(boxname)
		if (obj_box.style.display == "block")
			obj_box.style.display = "none";
		else
			obj_box.style.display = "block";
		var items = document.getElementsByTagName("input");
		for ( var i = 0; i < items.length; i++) {
			if (items[i].type == "checkbox" && items[i].name == gname
					&& items[i].checked == true) {
				e_str += items[i].value + ' ';
			}
		}
		obj.value = e_str;
		
	}
</script>
	</head>
	<body>
		<div id="待定">
			<form action="../email.do?method=write" method="post" name="frmmsg" id="frmmsg">
   			 <input type="hidden" name="method" value="add_Email">
				<br />
				<table border="1" bordercolor="#aaaaaa" width="680"
					bgcolor="#dfefff" style='border-collapse: collapse'>
					<tr>
						<td colspan="2" align="center">
							<font color="blue" size="5"><b>邮件发送表单</b>
							</font>
						</td>
					</tr>
					<tr>
						<td width="120" align="left">
							<font size='3' color='red'>*</font><b>发送至：</b>
						</td>
						<td>
							<input type='hidden' name="from" id="from" value="${member.realName }<%//这里放发送者姓名 %>">
							<input type='text' name="to" id="to" style="width: 180px;"
								value="<%//若是回复的话，要考虑获取回复给谁这个问题 %>">
							<div name="slt_box_to" id="slt_box_to"
								style="overflow-y: auto; width: 120px; height: 300px; float: float; z-index: 1000; position: absolute; top: 15%; left: 50%; border: #222222 1px solid; background-color: #ddddff; display: none">
								
								<%--<%
									//利用取得好友的模块，获得该用户的好友列表，以供选择
									List<MemberBaseInfo> friends = (List<MemberBaseInfo>)request.getAttribute("friends");
									for(int i=0;i<friends.size();i++){
										MemberBaseInfo friend = friends.get(i);
										out.println("<input type='checkbox' name='slt_to' value = '"+friend.getRealName()+"'>"+friend.getRealName()+"<br/>");	
									}
									
			
              					%>--%>
<!--              					<c:forEach items="${friends}" var="friend">-->
<!--              						${friend.id }-->
<!--              					</c:forEach>-->
								<input type='checkbox' name='slt_to' value = 'yanglj'>yanglj<br/>
								<input type='checkbox' name='slt_to' value = 'narci'>narci<br/>
								<br />
								<br />
								<center>
									<input type="button" value="确 定" onclick="javascript: show_list('to', 'slt_to', 'slt_box_to')";/>
								</center>
								<br />
							</div>
							<input type="button" value="选择" onclick="javascript:show_list('to', 'slt_to', 'slt_box_to');"/>
							<font color="#6666ff"> 填入好友的名字。若要群发可以输入"所有好友"。</font>
						</td>
					</tr>
					<tr>
						<td width="120" align="left">
							<font size='3' color='red'>*</font><b>标题：</b>
						</td>
						<td>
							<input type="text" name="title" id="title" style="width: 380px;">
							<font color="#6666ff" face="arial"> 不超过25个中文汉字</font>
						</td>
					</tr>
					<tr>
						<td width="120" align="left">
							<b>内容：</b>
						</td>
						<td>
							<div name="content_value" contenteditable=true id="content_value"
								style="width: 580px; height: 288px; background: #ffffff">
								<%//若是包含了回复功能，就要把回复的内容放进来 %>
							</div>
							<input type="hidden" id="content" name="content" />
						</td>
					</tr>
					<tr>
						<td align="center" colspan="2">
							<input type="submit" class="btn" value="确认提交"
								onClick="javascript: changeHTML();docheck();"/>
							&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
							<input type="reset" class="btn" value="重 置">
						</td>
					</tr>
					<tr>
						<td colspan="2">
							
						</td>
					</tr>
				</table>
				<br />
				<br />
				<table width="480">
					<tr>
						<td align="right">
							<INPUT TYPE='BUTTON' VALUE='关 闭' class="btn"
								onClick='javascript:window.close()'>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>